<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:69:"/home/wwwroot/www.xgw0851.com/application/index/view/address/add.html";i:1529206591;s:69:"/home/wwwroot/www.xgw0851.com/application/index/view/public/base.html";i:1530280572;}*/ ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="__PUBLIC__/xsd/css/mui.min.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/icons-extra.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/app.css?v1111121" />

</head>
<!--/head-->
<body>


	<!--/header-->

<link rel="stylesheet" type="text/css" href="__PUBLIC__/xsd/css/checkout.css" />
<style>
.mui-btn-block{
  padding: 5px;
  border: 1px solid #ccc !important;
  margin: 5px;
  -webkit-appearance: none;
}

.fill-section {
    padding-left: 15px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.fill-section li {
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

.fill-section li:last-child {
    border-bottom: none;
}
.fill-type {
    float: left;
    line-height: 44px;
}

.customer-section .fill-type {
    width: 50px;
}

.customer-section .fill-section-right {
    margin-left: 50px;
}

.fill-phone-right {
    position: relative;
}

.fill-input {
    width: 100%;
    height: 44px !important;
    line-height: 38px !important;
    border: 0 !important;
    font-size: 14px;
    padding: 0 !important;
}

.customer-gender {
    border-top: 1px solid #f0f0f0;
    height: 44px;
}

.customer-gender-choice {
    float: left;
    width: 50%;
    height: 44px;
    line-height: 44px;
    padding-left: 10px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.customer-gender-choice .i-circle {
    float: left;
    width: 16px;
    height: 16px;
    line-height: 16px;
    border: 1px solid #999;
    margin: 12px 8px 0 0;
}

.customer-gender-check .i-circle {
    width: 18px;
    height: 18px;
    line-height: 18px;
    border: 0;
    background-color: #ffd300;
    text-align: center;
    color: #6b450a;
    font-size: 14px;
    font-family: 'iconfonts';
}

.customer-gender-check .i-circle:before {
    content: '\e61a';
}

.address-section .fill-section-right {
    display: block;
    height: 44px;
    margin-left: 105px;
}

.addr-icon {
    float: left;
    margin-top: 10px;
    color: #888;
}

.addr-choose {
    display: block;
    padding: 0 !important;
    line-height: 44px !important;
    height: 44px !important;
    font-size: 13px;
    color: #333;
    border: 0 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: auto !important;

}

.addr-arrow {
    float: right;
    margin: 16px 12px 0 0;
    width: 10px;
    height: 10px;
    border: 1px solid #ddd;
    border-width: 1px 1px 0 0;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    transform: rotate(45deg);
}

.addr-save-btn {
    width: 93%;
    height: 44px;
    margin: 15px auto;
    background-color: #fff;
    color: #fa9700;
    font-size: 16px;
    line-height: 44px;
    text-align: center;
}

.addr-tip-list {
    position: absolute;
    left: 0;
    right: 0;
    top: 44px;
    z-index: 10;
    display: none;
    background-color: #f8f8f8;
    border: 1px solid #eaeaea;
}

.addr-tip-list li {
    height: 40px;
    padding: 3px 0 3px 3px;
    border-bottom: 1px solid #eaeaea;
}

.addr-tip-list li p {
    height: 40px;
    line-height: 40px;
    padding-left: 13px;
    color: #2f2f2f;
}

.addr-tip-list li.tip-selected p {
    height: 40px;
    background-color: #eaeaea;
}

.addr-tip-list li.tip-hide {
    display: none;
}
ul, ol {
    padding-left: 0;
    list-style-type: none;
}
</style>
<div id="content">
<header class="mui-bar mui-bar-nav" style="z-index:7">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">添加地址</h1>
</header>
<div class="mui-content ">
  <h5 style="margin:10px 5px;">联系人</h5>
  <div class="formbloack username" >
      <div class="label-wrap" >姓名</div>
      <div class="input-group-wrap" >
          <div class="input-wrap" > <input type="text" style="margin-bottom: 0;    padding-left: 0;" placeholder="收货人姓名" name="name" value="<?php echo $info['name']; ?>" > </div>
          <div class="input-wrap bottom" > <span class="form-radio" > <span class="radio-icon  <?php if($info['sex'] != '2'): ?>checked<?php endif; ?>" data-sex="1" ></span> 先生 </span> <span class="form-radio" > <span class="radio-icon <?php if($info['sex'] == '2'): ?>checked<?php endif; ?>" data-sex="2" ></span> 女士 </span>
          </div>
      </div>
  </div>

  <div class="formbloack phone" >
      <div class="label-wrap" >手机</div>
      <div class="input-group-wrap rightbtn">
          <div class="input-wrap" style="    padding: .173333rem 0;"> <input placeholder="收货人的手机号" type="tel" name="tel" value="<?php echo $info['tel']; ?>" style="margin-bottom: 0;    padding-left: 0;"> </div>
      </div>
  </div>
  <h5 style="margin:10px 5px;">收货地址</h5>

  <ul class="fill-section address-section">
    <?php if(\think\Cookie::get('address_type') == '1'): ?>
      <li>
          <span class="fill-type">详细地址：</span>
          <div class="fill-section-right">
              <input type="text" class="fill-input j-house-number" name="address" placeholder="" value="<?php echo $info['address']; ?>" />
              <input type="hidden"  name="type" value='1' />
          </div>
      </li>
    <?php else: ?>
    <li>
        <span class="fill-type">小区/大厦/学校：</span>
        <a class="fill-section-right showmap" href="javascript:;">
            <i class="icon-loc-hollow addr-icon mui-icon mui-icon-location"></i>
            <i class="addr-arrow"></i>
            <input type="text" class="addr-choose j-address" name="address" readonly placeholder="点击选择" value="<?php echo !empty($info['latlng'])?$info['address'] : ''; ?>" />
            <input type="hidden" class="addr-choose j-address" name="address_full" value="<?php echo !empty($info['latlng'])?$info['address_full'] : ''; ?>" />
            <input type="hidden" class="addr-choose j-address" name="latlng" value='<?php echo $info['latlng']; ?> ' />
              <input type="hidden"  name="type" value='0' />
        </a>
    </li>
    <li>
        <span class="fill-type">楼号－门牌号：</span>
        <div class="fill-section-right">
            <input type="text" class="fill-input j-house-number" name="house_number" placeholder="例16号楼427室" value="<?php echo $info['house_number']; ?>" />
        </div>
    </li>

    <script type="text/javascript" src="//3gimg.qq.com/lightmap/components/locationPicker2/js/main-62c2e3b971.js"></script>
    <script>
        //iframe页面调用方法
        $(function(){
            $('.showmap').on('click', function(){
                $('#map').show()
                $('#content').hide()
            })


            adaptHeight();//动态适配高度

            window.onresize = function() { //横屏、QQ浏览器变全屏模式下的时候，需要重新计算高度
                adaptHeight();
            }

            window.addEventListener('message', function(event) {
                var loc = event.data;
                //  alert('你使用的组件是'+loc.module+',刚选择了'+loc.poiname+',它位于'+loc.poiaddress+',它的经纬度是：'+loc.latlng.lat+','+loc.latlng.lng+',所属城市为:'+loc.cityname)
                $('[name="address"]').val(loc.poiname)
                $('[name="address_full"]').val(loc.poiaddress)
                $('[name="latlng"]').val( loc.latlng.lat+','+loc.latlng.lng)

                $('#map').hide()
                $('#content').show()
                $('[name="house_number"]').focus()
            }, false);

            function adaptHeight() {
                var winH = $(window).height();
                var bodyH = document.documentElement.clientHeight;
                if (winH > bodyH) {
                    window.parent.document.getElementById("iframe").height=winH;
                } else {
                    window.parent.document.getElementById("iframe").height=bodyH;
                }
            }
        });
    </script>
    <?php endif; ?>
  </ul>
  <input type="hidden" value="<?php echo $info['id']; ?>" name="id" />
  <div class="form-button-wrap" > <button class="form-button" type="button" id="addAddress" >提 交</button> </div>

</div>
</div>
<div id="map"  style="display:none;">
  <!-- 通过 iframe 嵌入地图选点组件 -->
  <iframe id="iframe" width="100%" frameborder=0 scrolling="no"
      src="http://apis.map.qq.com/tools/locpicker?search=1&type=1&policy=1&key=QQ6BZ-24HC6-ZAXSZ-MTZAU-5MU2J-HEFEH&referer=鲜果屋&coord=<?php echo \think\Cookie::get('positioninit'); ?>">
  </iframe>
</div>



<!--/#footer-->

<script src="__PUBLIC__/js/jquery.js"></script>
<script src="__PUBLIC__/xsd/js/mui.min.js"></script>
<script src="__PUBLIC__/xsd/js/flexible.js"></script>
<script src="__PUBLIC__/xsd/js/template.js"></script>



<script type="text/javascript">


  $(function(){
    $('[name="first_area"]').change(function(){
      var $this = $(this),id = $this.val();
      $('[name="second_area"]').html(' ');
      $.post("<?php echo url('index/index/getSecondArea'); ?>", {
          "id": id
      }, function(data) {

        var html = template('tpl', data);
        $('[name="second_area"]').html(html);

      }, "json");
    })
    $('[name="first_area"]').change();

    $('.form-radio').click(function(){
      $(this).find('.radio-icon').addClass('checked')
      $(this).siblings().find('.radio-icon').removeClass('checked')
    })


    $('#addAddress').click(function(){
          var name = $.trim($('[name="name"]').val()),
              sex = $(".form-radio").find('.checked').attr('data-sex'),
              tel = $.trim($('[name="tel"]').val()),
              id = $('[name="id"]').val(),
              address= $.trim($('[name="address"]').val()),
              address_full= $.trim($('[name="address_full"]').val()),
              latlng= $.trim($('[name="latlng"]').val()),
              house_number= $.trim($('[name="house_number"]').val()),
              type =  $.trim($('[name="type"]').val())
         if(!name){
           mui.toast('请输入收货人姓名')
           return;
         }
         if (!tel) {
              mui.toast("请输入号码！");
              return;
          }
         if (!address) {
              mui.toast("请选择地址！");
              return;
          }
         if ($('[name="house_number"]').length > 0 && !house_number) {
              mui.toast("请填写楼号－门牌号！");
              return;
          }

         $.post("<?php echo url('index/address/add'); ?>", {
           "id": id,
           "name": name,
           "sex": sex,
           "tel": tel,
           "address": address,
           "address_full": address_full,
           "latlng": latlng,
           "house_number": house_number,
           "type": type
         }, function(data) {
             if(data.code == 1){
               setTimeout(function() {
                 //mui.back();
                 //self.location=document.referrer;
                 window.location.href= data.url
               }, 1000);
             }
             mui.toast(data.msg)
         }, "json");
    })

    //地址类型
    $('[name="type"]').click(function(){
      var val = $(this).val();
      if(val != 1){
        $('#sqdz').show()
      }else{
        $('#sqdz').hide()
      }
    })
  })
</script>

<?php if(!(empty(config('shop_hours')) || (config('shop_hours') instanceof \think\Collection && config('shop_hours')->isEmpty()))): ?>
<script>
  var time_range = function (beginTime, endTime) {
    var strb = beginTime.split (":");
    if (strb.length != 2) {
      return false;
    }

    var stre = endTime.split (":");
    if (stre.length != 2) {
      return false;
    }

    var b = new Date ();
    var e = new Date ();
    var n = new Date ();

    b.setHours (strb[0]);
    b.setMinutes (strb[1]);
    e.setHours (stre[0]);
    e.setMinutes (stre[1]);

    if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
      return true;
    } else {

      mui.alert("<?php echo config('shop_hours_message'); ?>", '公告');
      $('.mui-popup-buttons').html(' ')
      $('.mui-popup-inner').css('border-radius', '13px')
      return false;
    }
  }

  var shop_hours = "<?php echo config('shop_hours'); ?>";
  var hours_arr = shop_hours.split('-');
  time_range (hours_arr[0], hours_arr[1]);

</script>
<?php endif; if(config('is_rest') == '1'): ?>
<script>
mui.alert("<?php echo config('rest_message'); ?>", '公告');
$('.mui-popup-buttons').html(' ')
$('.mui-popup-inner').css('border-radius', '13px')
</script>
<?php endif; if(empty(\think\Cookie::get('positioninit')) || (\think\Cookie::get('positioninit') instanceof \think\Collection && \think\Cookie::get('positioninit')->isEmpty())): ?>
<script type="text/javascript" src="https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js"></script>
<script>
   var geolocation = new qq.maps.Geolocation("QQ6BZ-24HC6-ZAXSZ-MTZAU-5MU2J-HEFEH", "鲜果屋");
    geolocation.getIpLocation(showPosition, showErr)
    function showPosition(position) {
      $.getJSON("<?php echo url('index/cart/changecookie'); ?>", {name: 'positioninit', 'val': position.lat+','+position.lng}, function(json, textStatus) {});
    };
    function showErr() {
      console.log('定位失败');
    };
</script>
<?php endif; ?>


<script>
  $(function(){
    $('.subsc').click(function(){
      // $.get("<?php echo url('index/clearusersession'); ?>", function(data){
      //   if(data.code == 1){
      //     window.location.href = "http://mp.weixin.qq.com/s/-AzpDTU7eAD24-R5QUP0wg"
      //   }
      // })
      //cookie('goodsmodel_id', $model_id);
      <?php switch(cookie('goodsmodel_id')): case "1":case "2":case "3": ?>
            mui.alert("<img src=<?php echo get_cover(config('frankserviceimg'), 'path'); ?> style='width:100%;'>", '长按扫二维码');
        <?php break; endswitch; if(!(empty($contact_qc) || ($contact_qc instanceof \think\Collection && $contact_qc->isEmpty()))): ?>
            mui.alert('<img src="<?php echo $contact_qc; ?>" style="width:100%;">', '长按扫二维码');
      <?php endif; ?>
    })


    $('.endlimit').each(function(){
      var $this = $(this);
      var stime = $this.attr('data-endtime');
      var starttime = new Date(stime.replace(/-/g,"/"))
      setInterval(function () {
        var nowtime = new Date();
        var time = starttime - nowtime;
        if(time > 0){
          var day = parseInt(time / 1000 / 60 / 60 / 24);
          var hour = parseInt(time / 1000 / 60 / 60 % 24);
          var minute = parseInt(time / 1000 / 60 % 60);
          var seconds = parseInt(time / 1000 % 60);
          $this.html("距结束还有:<span style='color:red'>"+ day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒</span>");
        }

      }, 1000);
    })

    $('.hidecartbtn').each(function(){
      var id = $(this).attr('data-id')
      $('.cartbtn'+id).hide();
    })


  })
</script>
</body>
</html>
